<?php
/**
 * Created by PhpStorm
 * User: Jhinwy
 * Date: 7/24/24
 * Time: 10:20 AM
 */

namespace app\adminapi\controller\template;


use app\adminapi\controller\BaseAdminController;
use app\adminapi\lists\template\TemplateLists;
use app\adminapi\logic\template\TemplateLogic;
use app\adminapi\validate\template\TemplateValidate;

/**
 * Template控制器
 * Class TemplateController
 * @package app\adminapi\controller
 */
class TemplateController extends BaseAdminController
{


    /**
     * @notes 获取列表
     * @return \think\response\Json
     * @author likeadmin
     * @date 2024/01/29 19:06
     */
    public function lists()
    {
        return $this->dataLists(new TemplateLists());
    }


    /**
     * @notes 添加
     * @return \think\response\Json
     * @author likeadmin
     * @date 2024/01/29 19:06
     */
    public function add()
    {
        $params = (new TemplateValidate())->post()->goCheck('add');
        $result = TemplateLogic::add($params);
        if (true === $result) {
            return $this->success('添加成功', [], 1, 1);
        }
        return $this->fail(TemplateLogic::getError());
    }


    /**
     * @notes 编辑
     * @return \think\response\Json
     * @author likeadmin
     * @date 2024/01/29 19:06
     */
    public function edit()
    {
        $params = (new TemplateValidate())->post()->goCheck('edit');
        $result = TemplateLogic::edit($params);
        if (true === $result) {
            return $this->success('编辑成功', [], 1, 1);
        }
        return $this->fail(TemplateLogic::getError());
    }


    /**
     * @notes 删除
     * @return \think\response\Json
     * @author likeadmin
     * @date 2024/01/29 19:06
     */
    public function delete()
    {
        $params = (new TemplateValidate())->post()->goCheck('delete');
        TemplateLogic::delete($params);
        return $this->success('删除成功', [], 1, 1);
    }



    /**
     * @notes 获取详情
     * @return \think\response\Json
     * @author likeadmin
     * @date 2024/01/29 19:06
     */
    public function detail()
    {
        $params = (new TemplateValidate())->goCheck('detail');
        $result = TemplateLogic::detail($params);
        return $this->data($result);
    }


}
